﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Windows;
using Caliburn.Micro;
using OPSYS_Schematic.UIInfrastructure;

namespace OPSYS_Schematic.Presentation.Parts
{
    [Export(typeof (ITheme))]
    [MenuPart(BaseMenu = WorkbenchName.ThemePart, PreviousMenu = WorkbenchName.ExpressionLightThemePart)]
    public class VS2010Theme : MenuPart, ITheme
    {
        private IEnumerable<ResourceDictionary> resources;

        public VS2010Theme()
            : base(WorkbenchName.VS2010ThemePart)
        {
            IsCheckable = true;
        }

        #region ITheme Members

        public IEnumerable<ResourceDictionary> Resources
        {
            get
            {
                if (resources == null)
                {
                    resources = new[]
                                    {
                                        this.LoadResourceDictionary(new Uri("Themes/Color_Light.xaml", UriKind.Relative))
                                        ,
                                        this.LoadResourceDictionary(new Uri("Themes/Theme_Expression.xaml",
                                                                            UriKind.Relative)),
                                        this.LoadResourceDictionary(
                                            new Uri("/AvalonDock.Themes;component/themes/dev2010.xaml", UriKind.Relative))
                                    };
                }
                return resources;
            }
        }

        #endregion

        public override void Execute()
        {
            IoC.Get<IThemeService>().ChangeTheme(Name);
        }
    }
}